<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<script type="text/javascript" src="js/2h5_fb.js"></script>
		<meta name="format-detection" content="telephone=yes" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
		<link rel="shortcut icon" href="img/icon/bitbug_favicon.ico">
		<link rel="stylesheet" href="css/mui/mui.css" />
		<link rel="stylesheet" href="css/withdraw/salarybill.css" />
		<title>工资列表</title>
	</head>

	<body>
		<div class="salarytitle">
			<div class="titlecon1">
				<img src="img/icon/date.png" />
			</div>
			<div class="titlecon2">
				<img src="img/icon/triangle1.png" class="triangle1" />
				<span class="month" id="month" data-options="{'type':'YYYY-MM','beginYear':2010,'endYear':2088}" style="width:2.213333rem;height:0.253333rem;color: #FFF;"></span>
				<img src="img/icon/triangle2.png" class="triangle2" />
			</div>
		</div>
		<div class="wrapbox" id="wrapbox"></div>

		<div class="emptybox">
			<img src="img/icon/empty.png" />
			<span>抱歉,没有相关记录</span>
		</div>

		<div style="position: fixed;display:table;margin: 0 auto;width: 0px;height: 0px;;top: 45%;left: 50%;right: 50%;z-index: 1000;">
			<div id="myspin" style="position: fixed;z-index: 10000;"></div>
		</div>

		<div class="phonecover"></div>
		<div class="phonebox">
			<div class="cf_bag"></div>
			<div class="phone_title1">手机号绑定</div>
			<div class="phone_con">
				<div class="phone_title2">
					<span class="title1">手机号</span>
					<input type="text" maxlength="11" class="phone" id="phoneNum" />
				</div>

				<div class="phone_title3">
					<span class="title2">验证码</span>
					<input type="text" maxlength="6" class="code" id="code" />
					<button type="button" class="code_txt" id="code_btn">获取验证码</button>
				</div>

			</div>
			<div class="phone_btn" id="phone_btn">确定</div>
		</div>

	</body>

	<script type="text/javascript" src="js/mui/mui.min.js"></script>
	<script type="text/javascript" src="js/jquery/jquery-2.1.4.min.js"></script>
	<script type="text/javascript" src="js/spin/spin.min.js"></script>
	<script type="text/javascript" src="js/common.js"></script>
	<script type="text/javascript" src="js/util/util.js"></script>
	<script type="text/javascript" src="app/server.js"></script>
	<script type="text/javascript" src="js/jquery/jquery.date.js"></script>
	<script type="text/javascript">
		var token = "";
		var spinner = new Spinner(opts);
		var openid = getParam("openid"); //微信openid
		var countentPhone = getParam("countentPhone"); //手机框 0弹出1不弹出
		var userName = getParam("userName"); //用户昵称
		var userUrl = getParam("userUrl"); //用户头像

		if(sessionStorage.getItem("cur_month")) {
			$("#month").html(sessionStorage.getItem("cur_month"));
		} else {
			$("#month").html(getYearMonth());
		}
		$.date('#month');
		if(openid != "" && openid != "null" && openid != null) {
			sessionStorage.setItem("openid", openid);
		}
		if(userName != "" && userName != "null" && userName != null) {
			sessionStorage.setItem("weixin_userName", decodeURI(userName));
		}
		if(userUrl != "" && userUrl != "null" && userUrl != null) {
			sessionStorage.setItem("weixin_userUrl", userUrl);
		}

		if(countentPhone == "0") {
			$(".phonecover").show();
			$(".phonebox").show();
		} else {
			//查询工资列表
			sessionStorage.setItem("salary_sign", 001188);
			var month = $("#month").html();
			sessionStorage.setItem("cur_month", month);
			var param = {};
			param.openid = sessionStorage.getItem("openid");
			param.month = month;
			querySalaryList(param, function(resultObj) {
				$("#wrapbox").empty();
				$(".emptybox").hide();
				if(resultObj.code == 0 && resultObj.data.length > 0) {
					for(var i = 0; i < resultObj.data.length; i++) {
						var html = '<div class="salarycon" onclick="querySaralyDetail(\'' + resultObj.data[i].salaryDetails + '\')"><div class="salary_logo">' +
							'<img src="img/icon/salary.png" /></div>' +
							'<div class="salary_company"><span class="company">' + resultObj.data[i].companyName + ' </span><span class="detail">点击查看明细</span></div>';
						$("#wrapbox").append(html);
					}
				} else if(resultObj.data.length == 0) {
					$(".emptybox").show();
				} else {
					mui.toast(resultObj.msg);
					return;
				}
			})
		}

		//获取验证码
		$("#code_btn").click(function() {
			var phoneNum = $("#phoneNum").val(); //手机号
			var flag = checkPhone(phoneNum);
			if(flag) {
				var param = {};
				param.phone = phoneNum;
				param.type = 6;
				//获取验证码接口上送
				gainCode(param, function(data) {
					token = data;
					//开启验证码定时器
					for(i = 1; i <= 60; i++) {
						if(i == 1) {
							window.setTimeout("countDown(" + i + ")");
						} else {
							window.setTimeout("countDown(" + i + ")", (i - 1) * 1000);
						}
					}
				});
			}
		})

		//手机号绑定确定
		$("#phone_btn").click(function() {
			var phone = $("#phoneNum").val(); //手机号
			var code = $("#code").val();
			//校验验证码接口上送
			var param = {};
			param.phone = phone;
			param.type = 6;
			param.code = code;
			param.token = token;
			mateCode(param, function() {
				var param = {};
				param.userid_sign = sessionStorage.getItem("openid");
				param.phone = phone;
				param.userName = sessionStorage.getItem("weixin_userName");
				param.userUrl = sessionStorage.getItem("weixin_userUrl");

				//微信绑定客户手机号
				bindCustomerPhone(param, function(resultObj) {
					closeSpin();
					$(".phonecover").hide();
					$(".phonebox").hide();

					//查询工资列表
					sessionStorage.setItem("salary_sign", 001188);
					var month = $("#month").html();
					sessionStorage.setItem("cur_month", month);
					var param = {};
					param.openid = sessionStorage.getItem("openid");
					param.month = month;
					querySalaryList(param, function(resultObj) {
						$("#wrapbox").empty();
						$(".emptybox").hide();
						if(resultObj.code == 0 && resultObj.data.length > 0) {
							for(var i = 0; i < resultObj.data.length; i++) {
								var html = '<div class="salarycon" onclick="querySaralyDetail(\'' + resultObj.data[i].salaryDetails + '\')"><div class="salary_logo">' +
									'<img src="img/icon/salary.png" /></div>' +
									'<div class="salary_company"><span class="company">' + resultObj.data[i].companyName + ' </span><span class="detail">点击查看明细</span></div>';
								$("#wrapbox").append(html);
							}
						} else if(resultObj.data.length == 0) {
							$(".emptybox").show();
						} else {
							mui.toast(resultObj.msg);
							return;
						}
					})
				});
			})
		})

		/**
		 * 查询账单详情
		 * @param {Object} id
		 */
		function querySaralyDetail(detail) {
			window.location.href = "app/withdraw/salarybill_detail.html?detail=" + detail;
		}
	</script>

</html>